/**
 * 获取页面数据
 * url：请求路劲
 * param：提交参数
 * reload：是否刷新页面
 */
function getData(url, param={}, reload=''){
	$.ajax({  
		type:'post',    
	    url: url,  
	    data:'data=' + JSON.stringify(param),  
	    cache:false,  
	    dataType:'json',  
	    async:false,
	    success:function(res){  
	    	if(res.msg){
	    		if(res.status == 'success'){
	    			showMsg('温馨提示', res.msg, '', reload);		    		
		    	}else{
		    		var msg = '网络错误，请刷新页面重试';
		    		if(res.msg){
		    			msg = res.msg;
		    		}
		    		showMsg('温馨提示', msg);
		    	}
	    	}else{
	    		resData = res;
	    	}
	    }  
	})
}

/**
 * 单独只获取数据似乎会更好
 */
function getData2(url, param={}){
	var data = '';
	$.ajax({  
		type:'post',    
	    url: url,  
	    data:'data=' + JSON.stringify(param),  
	    cache:false,  
	    dataType:'json',  
	    async:false,
	    success:function(res){  
	    	data = res;
	    }  
	})
	return data;
}

//倒计时结束提示弹框
function showMsg(title='温馨提示', msg, type, reload=''){
	if(!title){return}
	switch(type){
		case 'bet':
			var bet_status = false;
			layer.open({
				title: title,
				content: msg,
				className: 'layui-m-tag-msg',
				btn: ['投注','取消'],
				yes: function (index){
					doBet();
		        	layer.close(index);
				}
			});
			break;
		case 'success':
			layer.open({
	            title: '温馨提示',
	            content: '<span style="color:red">投注成功</span>，您可以在我的账户查看注单详情',
	            className: 'layui-m-tag-msg',
	            btn: ['继续投注', '查看注单'],
	            yes: function (index){
					// 继续投注
	            	layer.close(index);
	            },
	            no: function (index){
	            	// 查看注单
	            	window.location = memberBet;
	            }
	        });
			break;
		default:
			layer.open({
				title: title,
				content: msg,
				className: 'layui-m-tag-msg',
				btn: ['确定'],
				yes: function (index){
					layer.close(index);
					if(reload){
						window.location.reload();
					}
				}
			});
			break;
	}
}

/**
 * 随机生成投注号（当前选择玩法规则下）
 */
function randBet(){
	var choiceItem = [];
	var sscItem    = '';
	// 获取玩法的选项内容 // 吐了吐了
	if(play_follow.base.item.item_rule){
		if(!$.isEmptyObject(resData.playItem.baseItem[play_follow.base.item.item_rule])){
			sscItem = resData.playItem.baseItem[play_follow.base.item.item_rule];
			// 时时彩的手动输入对应选项
			if(!$.isEmptyObject(sscItem.routine)){
				$.each(sscItem.routine, function (i, v){
					choiceItem.push(v);
				});
			}else{
				for(var i = sscItem.min; i <= sscItem.max; i++){
					choiceItem.push(parseInt(i));
				}
			}
		}else{
			syxwItem = resData.playItem.baseItem;
			// 这里为十一选五的玩法配置， 没有时时彩设计的好。
			$.each(syxwItem, function (i, v){
				choiceItem.push(parseInt(v.title));
			})
		}
	}else{
		if( (typeof play_follow.base.item[1].option) != 'object'){
			// 如果玩法的投注项不是数组， 则是标准投注项
			if((typeof resData.playItem.baseItem[play_follow.base.item[1].option]) == 'object'){
				// 兼容写法， 十一选五与时时彩的baseItem配置不一样，没有做统一规划
				sscItem = resData.playItem.baseItem[play_follow.base.item[1].option];
				// sscItem这里获取的为ssc的玩法， 时时彩的玩法配置要更完善
				if(!$.isEmptyObject(sscItem.routine)){
					$.each(sscItem.routine, function (i, v){
						choiceItem.push(v);
					});
				}else{
					for(var i = sscItem.min; i <= sscItem.max; i++){
						choiceItem.push(parseInt(i));
					}
				}
			}else{
				// 这里为十一选五的玩法配置， 没有时时彩设计的好。
				if((typeof play_follow.base.item[1].option) != 'object'){
					$.each(resData.playItem.baseItem, function (i, v){
						choiceItem.push(parseInt(v.title));
					})
				}else{
					$.each(play_follow.base.item[1].option, function (i, v){
						choiceItem.push(v.title);
					})
				}
			}
		}else{
			$.each(play_follow.base.item[1].option, function (i, v){
				choiceItem.push(v.title);
			})
		}
	}
	
	// 打乱数组=随机了
	choiceItem.sort(randomsort);
	var cpItem = [];
	cpItem            = choiceItem;
	// 十一选五最多3组选项，时时彩最多5组选项
	var one           = choiceItem[0];
	var two           = choiceItem[1];
	var three         = choiceItem[2];
	var four          = choiceItem[3];
	var five          = choiceItem[4];
	// 有些玩法一致，只是需要的投注项数目不一样
	var nums          = 0;
	// 时时彩玩法中和值的注数是特定
	var zhus          = 0; 
	cart_index++;
	// 构建基础准备投注数据
	ready_bet = {
		'bet_amount':default_bet_money,  // 随机生成的投注信息，单注总金额默认
		'bet_beishu':'1',                // 随机生成的投注信息，默认1倍
        'bet_money_unit':'1.00',             // 默认1元
        'bet_name'      :user_play,
        'bet_unit'      :'0',                // 舍弃提交，这里还是补上
    	'bet_zhushu'    :'1',
    	'multiple'      :'1',                // 默认倍数
     	'cart_index'    :cart_index,             // 操作购物车的时候需要用到
    	'eo_money'      :default_bet_money,
    	'period'        :'',                     // 期号信息，后台另外获取
    	'bet_string'    :'',                     // 投注内容展示
    	'maxwinner'     :'',                     // 赔率
    	'lott_id'       :resData.lotteryInfo.id, // 当前彩种id
    	'betting'       :{
    		'one':[],
    		'two':[],
    		'three':[],                          // 时时彩这里有五个元素
    		'four':[],
    		'five':[],
    	},
    	'bet_item':[
            {
				'bet':[],                        // 有效投注项
				'check':'success',
				'eo_money':default_bet_money,
				'multiple':'1',                  // 默认倍数
				'nums'    : '1',                 // 默认注数
            }
        ],
	};
	// 因为当初设计ssc与syxw购物车时， 没有统一设计， betting选项syxw是英文下标，ssc是数字下标。
	// 这里做判断调整
	var sscPlayItemCheck = [
            'YX-DWD|FS',  'QE-ZHI_X|FS', 'HE-ZHI_X|FS', 'QE-ZHI_X|DS', 'QE-ZHI_X|HZ',
            'HE-ZHI_X|HZ', 'QE-ZHI_X|KD', 'HE-ZHI_X|KD', 'QE-ZU_X|FS', 'HE-ZU_X|FS',
            'QE-ZU_X|DS', 'QE-ZU_X|HZ', 'HE-ZU_X|HZ', 'QE-ZU_X|BD', 'HE-ZU_X|BD',
            'QS-ZHI_X|FS', 'ZS-ZHI_X|FS', 'HS-ZHI_X|FS', 'QS-ZHI_X|HZ','ZS-ZHI_X|HZ',
            'HS-ZHI_X|HZ',  'QS-ZHI_X|KD', 'ZS-ZHI_X|KD', 'HS-ZHI_X|KD', 'QS-ZU_X|HZ',
            'ZS-ZU_X|HZ', 'HS-ZU_X|HZ', 'QS-ZU_X|ZS', 'ZS-ZU_X|ZS', 'HS-ZU_X|ZS',
            'QS-ZU_X|ZL', 'ZS-ZU_X|ZL', 'HS-ZU_X|ZL', 'QS-ZU_X|BD', 'ZS-ZU_X|BD',
            'HS-ZU_X|BD', 'QS-BDW|YM', 'ZS-BDW|YM', 'HS-BDW|YM','SI_X-BDW|YM',
            'WU_X-BDW|YM',  'QS-BDW|EM', 'ZS-BDW|EM', 'HS-BDW|EM', 'SI_X-BDW|EM',
            'WU_X-BDW|EM', 'WU_X-BDW|SM', 'SI_X-ZHI_X|FS', 'SI_X-ZU_X|ZX24', 'SI_X-ZU_X|ZX12',
            'SI_X-ZU_X|ZX6', 'SI_X-ZU_X|ZX4', 'WU_X-ZHI_X|FS', 'WU_X-ZU_X|ZX120', 'WU_X-ZU_X|ZX60',
            'WU_X-ZU_X|ZX30', 'WU_X-ZU_X|ZX20', 'WU_X-ZU_X|ZX10', 'WU_X-ZU_X|ZX5','WU_X-QW|YFFS',
            'WU_X-QW|HSCS',  'WU_X-QW|SXBX', 'WU_X-QW|SJFC', 'DXDS-DXDS|QE', 'DXDS-DXDS|HE',
            'DXDS-DXDS|QS', 'DXDS-DXDS|HS', 'QE-ZHI_X|DS', 'HE-ZHI_X|DS', 'QE-ZU_X|DS',
            'HE-ZU_X|DS', 'QS-ZHI_X|DS', 'ZS-ZHI_X|DS', 'HS-ZHI_X|DS', 'QS-ZU_X|HHZX',
            'ZS-ZU_X|HHZX', 'HS-ZU_X|HHZX', 'QS-ZU_X|ZSDS', 'ZS-ZU_X|ZSDS','HS-ZU_X|ZSDS',
            'QS-ZU_X|ZLDS', 'ZS-ZU_X|ZLDS', 'HS-ZU_X|ZLDS', 'SI_X-ZHI_X|DS', 'WU_X-ZHI_X|DS',
        ];
	if ($.inArray(user_play, sscPlayItemCheck) > -1){
		ready_bet.betting = {'1':[], '2':[], '3':[], '4':[], '5':[]}
	}
	switch(user_play){
		case 'SM-QS_ZHI_XFS':
			// 从数组中弹出三个数值， 分别加入到三个对应的选择位置（第一位，第二位，第三位）
		case 'SM-QS_ZHI_XDS':
			ready_bet.betting.one.push(one);
			ready_bet.betting.two.push(two);
			ready_bet.betting.three.push(three);
			ready_bet.bet_item[0].bet = [one, two, three];
			ready_bet.bet_string   = one + ',' + two + ',' + three;
			break;
		case 'SM-QS_ZU_XFS':
		case 'SM-QS_ZU_XDS':
			ready_bet.betting.one.push(one);
			ready_bet.betting.one.push(two);
			ready_bet.betting.one.push(three);
			ready_bet.bet_item[0].bet = [one, two, three];
			ready_bet.bet_string   = one + ' ' + two + ' ' + three;
			break;
		case 'SM-QS_ZU_XDT':
			ready_bet.betting.one.push(one);
			ready_bet.betting.two.push(two);
			ready_bet.betting.two.push(three);
			ready_bet.bet_item[0].bet = [one, two, three];
			ready_bet.bet_string   = one + ',' + two + ' ' + three;
			break;
		case 'EM-QE_ZHI_XFS':
		case 'EM-QE_ZHI_XDS':
			ready_bet.betting.one.push(one);
			ready_bet.betting.two.push(two);
			ready_bet.bet_item[0].bet = [one, two];
			ready_bet.bet_string   = one + ',' + two;
			break;
		case 'EM-QE_ZU_XFS':
		case 'EM-QE_ZU_XDS':
			ready_bet.betting.one.push(one);
			ready_bet.betting.one.push(two);
			ready_bet.bet_item[0].bet = [one, two];
			ready_bet.bet_string   = one + ' ' + two;
			break;
		case 'EM-QE_ZU_XDT':
			ready_bet.betting.one.push(one);
			ready_bet.betting.two.push(two);
			ready_bet.bet_item[0].bet = [one, two];
			ready_bet.bet_string   = one + ',' + two;
			break;
		case 'BDW-QSYMBDW':
			ready_bet.betting.one.push(one);
			ready_bet.betting.two.push(two);
			ready_bet.bet_item[0].bet = [one, two];
			ready_bet.bet_string   = one + ',' + two;
			break;
		case 'DWD-FS':
			// 不定位：复式
			var cpItem1 = cpItem;
			cpItem.sort(randomsort);
			cpItem1.sort(randomsort);
			two    = cpItem.pop();
			three  = cpItem1.pop();
			ready_bet.betting.one.push(one);
			ready_bet.betting.two.push(two);
			ready_bet.betting.three.push(three);
			ready_bet.bet_item[0].bet = [one, two, three];
			ready_bet.bet_string   = one + ',' + two + ',' + three;
			break;
		case 'QWX-DDS':
		case 'QWX-CZW':
			ready_bet.betting.one.push(one);
			ready_bet.bet_item[0].bet = [one];
			ready_bet.bet_string   = one;
			break;
		case 'RXFS-YZY':
		case 'RXDS-YZY':
			nums = 1;
		case 'RXFS-EZE':
		case 'RXDS-EZE':
			nums = nums ? nums : 2;
		case 'RXFS-SZS':
		case 'RXDS-SZS':
			nums = nums ? nums : 3;
		case 'RXFS-SI_Z_SI':
		case 'RXDS-SI_Z_SI':
			nums = nums ? nums : 4;
		case 'RXFS-WZW':
		case 'RXDS-WZW':
			nums = nums ? nums : 5;
		case 'RXFS-LZW':
		case 'RXDS-LZW':
			nums = nums ? nums : 6;
		case 'RXFS-QZW':
		case 'RXDS-QZW':
			nums = nums ? nums : 7;
		case 'RXFS-BZW':
		case 'RXDS-BZW':
			nums = nums ? nums : 8;
			for(var i = 0; i < nums; i++){
				one = cpItem.pop();
				ready_bet.betting.one.push(one);
				ready_bet.bet_string  += one + ' ';
			}
			ready_bet.bet_item[0].bet = ready_bet.betting.one;
			break;
		case 'RXDT-EZE':
			nums = 1;
		case 'RXDT-SZS':
			nums = nums ? nums : 2;
		case 'RXDT-SI_Z_SI':
			nums = nums ? nums : 3;
		case 'RXDT-WZW':
			nums = nums ? nums : 4;
		case 'RXDT-LZW':
			nums = nums ? nums : 5;
		case 'RXDT-QZW':
			nums = nums ? nums : 6;
		case 'RXDT-BZW':
			nums = nums ? nums : 7;
			var danma = cpItem.pop();
			ready_bet.betting.one  = [danma];
			ready_bet.bet_string   = danma + ',';
			ready_bet.bet_item[0].bet = [danma];
			for(var i = 0; i < nums; i++){
				one = cpItem.pop();
				ready_bet.betting.two.push(one);
				ready_bet.bet_string  += one + ' ';
				ready_bet.bet_item[0].bet.push(one);
			}
			break;
		// ==========================================================
		// 时时彩部分             ==========================================
		case 'YX-DWD|FS':
			var randBet  = '';
			var randType = GetRandomNum(1, 5);
			// 用随机数来控制定位胆
			switch(randType.toString()){
				case '1':
					randBet = one;
					ready_bet.betting[1].push(one);
					ready_bet.bet_item[0].bet = [one];
					break;
				case '2':
					randBet = two;
					ready_bet.betting[2].push(two);
					ready_bet.bet_item[0].bet = [two];
					break;
				case '3':
					randBet = three;
					ready_bet.betting[3].push(three);
					ready_bet.bet_item[0].bet = [three];
					break;
				case '4':
					randBet = four;
					ready_bet.betting[4].push(four);
					ready_bet.bet_item[0].bet = [four];
					break;
				case '5':
					randBet = five;
					ready_bet.betting[5].push(five);
					ready_bet.bet_item[0].bet = [five];
					break;
				default:
					break;
			}
			ready_bet.bet_string   = randBet;
			break;
		case 'QE-ZHI_X|FS':
		case 'QE-ZHI_X|DS':
		case 'QE-ZU_X|FS':
		case 'QE-ZU_X|DS':
		case 'HE-ZHI_X|FS':
		case 'HE-ZHI_X|DS':
		case 'HE-ZU_X|FS':
		case 'HE-ZU_X|DS':
			ready_bet.betting[1].push(one);
			ready_bet.betting[2].push(two);
			ready_bet.bet_item[0].bet = [one, two];
			ready_bet.bet_string   = one + ',' + two;
			break;
		case 'QE-ZHI_X|HZ':
		case 'QE-ZHI_X|KD':
		case 'QE-ZU_X|HZ':
		case 'QE-ZU_X|BD':
		case 'HE-ZHI_X|HZ':
		case 'HE-ZHI_X|KD':
		case 'HE-ZU_X|HZ':
		case 'HE-ZU_X|BD':
		case 'QS-ZHI_X|HZ':
		case 'QS-ZHI_X|KD':
		case 'QS-ZU_X|HZ':
		case 'QS-ZU_X|BD':
		case 'ZS-ZHI_X|HZ':
		case 'ZS-ZHI_X|KD':
		case 'ZS-ZU_X|HZ':
		case 'ZS-ZU_X|BD':
		case 'HS-ZHI_X|HZ':
		case 'HS-ZHI_X|KD':
		case 'HS-ZU_X|HZ':
		case 'HS-ZU_X|BD':
			// 和值需要找出其投注的注数
			ready_bet.betting[1]   = [one];
			ready_bet.bet_item[0].bet = [one];
			ready_bet.bet_string   = one;
			// 设置注数
			zhus                       = play_follow.base.item[1].every_bets[one];
			ready_bet.bet_zhushu       = zhus;
			ready_bet.bet_item[0].nums = zhus;
			break;
		case 'QS-ZHI_X|FS':
		case 'QS-ZHI_X|DS':
		case 'QS-ZU_X|HHZX':
		case 'ZS-ZHI_X|FS':
		case 'ZS-ZHI_X|DS':
		case 'ZS-ZU_X|HHZX':
		case 'HS-ZHI_X|FS':
		case 'HS-ZHI_X|DS':
		case 'HS-ZU_X|HHZX':
			cpItem.sort(randomsort)
			two   = cpItem[0];
			cpItem.sort(randomsort)
			three = cpItem[0];
			ready_bet.betting[1].push(one);
			ready_bet.betting[2].push(two);
			ready_bet.betting[3].push(three);
			ready_bet.bet_item[0].bet = [one, two, three];
			ready_bet.bet_string   = one + ',' + two + ',' + three;
			break;
		case 'QS-ZU_X|ZS':
		case 'QS-ZU_X|ZSDS':
		case 'ZS-ZU_X|ZS':
		case 'ZS-ZU_X|ZSDS':
		case 'HS-ZU_X|ZS':
		case 'HS-ZU_X|ZSDS':
			ready_bet.betting[1].push(one);
			ready_bet.betting[1].push(one);
			ready_bet.betting[2].push(two);
			ready_bet.bet_item[0].bet = [one, one, two];
			ready_bet.bet_string   = one + ',' + two;
			break;
		case 'QS-ZU_X|ZL':
		case 'QS-ZU_X|ZLDS':
		case 'ZS-ZU_X|ZL':
		case 'ZS-ZU_X|ZLDS':
		case 'HS-ZU_X|ZL':
		case 'HS-ZU_X|ZLDS':
			ready_bet.betting[1].push(one);
			ready_bet.betting[2].push(two);
			ready_bet.betting[3].push(three);
			ready_bet.bet_item[0].bet = [one, two, three];
			ready_bet.bet_string   = one + '' + two + ' ' + three;
			break;
		case 'QS-BDW|YM':
		case 'ZS-BDW|YM':
		case 'HS-BDW|YM':
		case 'SI_X-BDW|YM':
		case 'WU_X-BDW|YM':
			ready_bet.betting[1].push(one);
			ready_bet.bet_item[0].bet = [one];
			ready_bet.bet_string   = one;
			break;
		case 'QS-BDW|EM':
		case 'ZS-BDW|EM':
		case 'HS-BDW|EM':
		case 'SI_X-BDW|EM':
		case 'WU_X-BDW|EM':
			ready_bet.betting[1].push(one);
			ready_bet.betting[2].push(two);
			ready_bet.bet_item[0].bet = [one, two];
			ready_bet.bet_string   = one + ',' + two;
			break;
		case 'WU_X-BDW|SM':
			ready_bet.betting[1].push(one);
			ready_bet.betting[2].push(two);
			ready_bet.betting[3].push(three);
			ready_bet.bet_item[0].bet = [one, two, three];
			ready_bet.bet_string   = one + ',' + two + ',' + three;
			break;
		case 'SI_X-ZHI_X|FS':
		case 'SI_X-ZHI_X|DS':
		case 'SI_X-ZU_X|ZX24':
			ready_bet.betting[1].push(one);
			ready_bet.betting[2].push(two);
			ready_bet.betting[3].push(three);
			ready_bet.betting[4].push(four);
			ready_bet.bet_item[0].bet = [one, two, three, four];
			ready_bet.bet_string   = one + ',' + two + ',' + three + ',' + four;
			break;
		case 'SI_X-ZU_X|ZX12':
			ready_bet.betting[1].push(one);
			ready_bet.betting[2].push(two);
			ready_bet.betting[2].push(three);
			ready_bet.bet_item[0].bet = [one, one, two, three];
			ready_bet.bet_string   = one + ',' + one + ',' + two + ',' + three;
			break;
		case 'SI_X-ZU_X|ZX6':
			ready_bet.betting[1].push(one);
			ready_bet.betting[2].push(two);
			ready_bet.bet_item[0].bet = [one, one, two, two];
			ready_bet.bet_string   = one + ',' + one + ',' + two + ',' + two;
			break;
		case 'SI_X-ZU_X|ZX4':
			ready_bet.betting[1].push(one);
			ready_bet.betting[2].push(two);
			ready_bet.bet_item[0].bet = [one, two, two, two];
			ready_bet.bet_string   = one + ',' + two + ',' + two + ',' + two;
			break;
		case 'WU_X-ZHI_X|FS':
		case 'WU_X-ZHI_X|DS':
		case 'WU_X-ZU_X|ZX120':
			ready_bet.betting[1].push(one);
			ready_bet.betting[2].push(two);
			ready_bet.betting[3].push(three);
			ready_bet.betting[4].push(four);
			ready_bet.betting[5].push(five);
			ready_bet.bet_item[0].bet = [one, two, three, four, five];
			ready_bet.bet_string   = one + ',' + two + ',' + three + ',' + four + ',' + five;
			break;
		case 'WU_X-ZU_X|ZX60':
			ready_bet.betting[1].push(one);
			ready_bet.betting[2].push(two);
			ready_bet.betting[2].push(three);
			ready_bet.betting[2].push(four);
			ready_bet.bet_item[0].bet = [one, one, two, three, four];
			ready_bet.bet_string   = one + ',' + one + ',' + two + ',' + three + ',' + four;
			break;
		case 'WU_X-ZU_X|ZX30':
			ready_bet.betting[1].push(one);
			ready_bet.betting[1].push(two);
			ready_bet.betting[2].push(three);
			ready_bet.bet_item[0].bet = [one, one, two, two, three];
			ready_bet.bet_string   = one + ',' + one + ',' + two + ',' + two + ',' + three;
			break;
		case 'WU_X-ZU_X|ZX20':
			ready_bet.betting[1].push(one);
			ready_bet.betting[2].push(two);
			ready_bet.betting[2].push(three);
			ready_bet.bet_item[0].bet = [one, one, one, two, three];
			ready_bet.bet_string   = one + ',' + one + ',' + one + ',' + two + ',' + three;
			break;
		case 'WU_X-ZU_X|ZX10':
			ready_bet.betting[1].push(one);
			ready_bet.betting[2].push(two);
			ready_bet.bet_item[0].bet = [one, one, one, two, two];
			ready_bet.bet_string   = one + ',' + one + ',' + one + ',' + two + ',' + two;
			break;
		case 'WU_X-ZU_X|ZX5':
			ready_bet.betting[1].push(one);
			ready_bet.betting[2].push(two);
			ready_bet.bet_item[0].bet = [one, one, one, one, two];
			ready_bet.bet_string   = one + ',' + one + ',' + one + ',' + one + ',' + two;
			break;
		case 'WU_X-QW|YFFS':
		case 'WU_X-QW|HSCS':
		case 'WU_X-QW|SXBX':
		case 'WU_X-QW|SJFC':
			ready_bet.betting[1].push(one);
			ready_bet.bet_item[0].bet = [one];
			ready_bet.bet_string   = one;
			break;
		case 'DXDS-DXDS|QE':
		case 'DXDS-DXDS|HE':
		case 'DXDS-DXDS|QS':
		case 'DXDS-DXDS|HS':
			ready_bet.betting[1].push(one);
			ready_bet.betting[2].push(two);
			ready_bet.bet_item[0].bet = [one, two];
			ready_bet.bet_string   = one + ',' + two;
			break;
	}
	// 添加到购物车
	addCart();
}

// 打乱数组顺序
function randomsort(a, b) {
	// 用Math.random()函数生成0~1之间的随机数与0.5比较，返回-1或1
    return Math.random()>.5 ? -1 : 1;
}

function GetRandomNum(Min,Max){   
	var Range = Max - Min;   
	var Rand = Math.random();   
	return(Min + Math.round(Rand * Range));   
}

/**
 * 获取上一期的开奖情况
 */
function getLastPerOpen(){
	if($.isEmptyObject(resData.shangqi)) return;
	var lastPerRequest = {'operation':'getPerInfo', 'pid':resData.shangqi.id};
	$.ajax({  
		type:'post',    
	    url: getLastData,  
	    data:'data=' + JSON.stringify(lastPerRequest),  
	    cache:false,  
	    dataType:'json',  
	    success:function(res){  
	    	if(res.perInfo.code){
	    		// 清除settimeout
	    		clearTimeout(clear_kj_ready);
	    		// 调用上期开奖
	    		shangqi_kaijiang(res.perInfo.code);
	    	}
	    }
	})
	setTimeout("getLastPerOpen()", 1000*60);
}


function pageLoad(){
	getData(getDataUrl, requestParam);
	setTimeout("getLastPerOpen()", 1000*2);
}